const Koa = require('koa');
const app = new Koa();
const fs = require('fs');
const path=require('path');
const render = require('koa-ejs');
const Router = require('koa-router');
const router = new Router();
const staticServer=require('koa-static');
const views =require('koa-views');
const ejs=require('ejs');

const indexRouter=require('./routes/index');
//指定静态资源路径
app.use(staticServer(path.join(__dirname,'public')));

//layout
render(app, {
    root: path.join(__dirname, 'view'),
    layout: false,
    viewExt: 'html',
    cache: false,
    debug: false
});

router.use('/',indexRouter.routes());
// router.get('/',async (ctx, next) => {
//     await ctx.render('index')
// });

router.get('/product',async (ctx, next) => {
    await ctx.render('product')
});


app.use(router.routes());

const port = 9988;

app.listen(port);

console.log("Express server listening on port " + port);
console.log('......................................');
